import request from '../../utils/request.js'
const state = {
	test:"测试数据",
	indexData:{},//首页数据
	indexCateList:[]//三个分类数据
}
const mutations = {
	//修改首页数据
	changeIndexDataMutations(state,indexData){
		state.indexData = indexData
	},
	
	changeCateListMutations(state,indexCateList){
		state.indexCateList = indexCateList
	}
	
}
const actions = {
	//发送网络请求拿首页数据
	async getIndexDataActions({commit}){
		//1、执行异步请求
		const res = await request('/getIndexData');
		//2、触发mutations 存放拿到的数据
		 commit('changeIndexDataMutations',res.categoryData)
	},
	//获取三个分类数据
	async getIndexCatelistAction({commit}){
		const res = await request('/getIndexCatelist')
	   commit('changeCateListMutations',res.indexCateList)
	}
}
const gettters = {
	
}
export default {
	namespaced:true, // 不添加namespaced 只有state是模块化，其他的非模块化
	state,
	mutations,
	actions,
	gettters
}